import { createApp } from 'vue'
import App from './App.vue'

/* 引入组件 */
import { createPinia } from 'pinia'
import router from './common/router'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue';

/* 引入基础设施 */
import initTypeExetend from '@/common/types/type_exetend'
import globalPlugin from '@/common/plugin/global'
import { computeFontSize } from '@/common/infrastructure/utils'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

/* 引入样式 */
import './resources/styles/normalize.less'
import 'element-plus/dist/index.css'
import './resources/styles/element_extend.less'

/* 主程序 */
const app = createApp(App)

// 运行自动计算字体大小
computeFontSize()


// 定义全局属性
app.config.globalProperties.foo = 'bar'
app.config.globalProperties.$foo2323 = 'bar'

// 初始化类型扩展
initTypeExetend()

// 应用Pinia
app.use(createPinia())

// 应用Router
app.use(router)

// 应用插件
app.use(globalPlugin)

// 应用Element
app.use(ElementPlus, { locale: zhCn })

// 注册全局 Icon组件
for (const [ key, component ] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.mount('#app')

